<template>
  <div class='container'>
    <el-card>
      <span style="color:pink;font-size:12px">by祝楼帅</span>
      <div class="q_title">
        <span style="color:pink;font-size:12px">说明：目前支持学科和关键字条件筛选</span>
        <el-button type="success" icon="el-icon-edit" size="small" @click="$router.push('new')">新增试题</el-button>
      </div>
      <el-form :model="searchForm" ref="searchFormRefs" label-width="80px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="学科" prop="subjectID">
              <el-select v-model="searchForm.subjectID" placeholder="请选择" size="small" @change="selectChanged">
                <el-option :label="item.label" :value="item.value" v-for="item in subjectList" :key="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="二级目录" prop="catalogID">
              <el-select v-model="searchForm.catalogID" placeholder="请选择" size="small">
                <el-option :label="item.label" :value="item.value" v-for="item in secondList" :key="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="标签" prop="tags">
              <el-select v-model="searchForm.tags" placeholder="请选择" size="small">
                <el-option :label="item.label" :value="item.value" v-for="item in tagsList" :key="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="关键字" prop="keyword">
              <el-input v-model="searchForm.keyword" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="试题类型" prop="questionType">
              <el-select v-model="searchForm.questionType" placeholder="请选择" size="small">
                <el-option :label="item.label" :value="item.value" v-for="item in questionType" :key="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="难度" prop="difficulty">
              <el-select v-model="searchForm.difficulty" placeholder="请选择" size="small">
                <el-option :label="item.label" :value="item.value" v-for="item in difficulty" :key="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="方向" prop="direction">
              <el-select v-model="searchForm.direction" placeholder="请选择" size="small">
                <el-option :label="item" :value="item" v-for="(item,index) in direction" :key="index">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="录入人" prop="creatorID">
              <el-select v-model="searchForm.creatorID" placeholder="请选择" size="small">
                <el-option :label="item.username" :value="item.id" v-for="item in userList" :key="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="题目备注" prop="remarks">
              <el-input v-model="searchForm.remarks" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="企业简称" prop="shortName">
              <el-input v-model="searchForm.shortName" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="城市">
              <el-select v-model="searchForm.province" placeholder="请选择" size="small" style="width:48%;margin-right:2%"
                @change="selectListChanged">
                <el-option :label="item" :value="item" v-for="(item,index) in provinceList" :key="index">
                </el-option>
              </el-select>
              <el-select v-model="searchForm.city" placeholder="请选择" size="small" style="width:50%;">
                <el-option :label="item" :value="item" v-for="(item,index) in cityList" :key="index">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item style="text-align: right;">
              <el-button size="small" @click="clear">清除</el-button>
              <el-button type="primary" size="small" @click="getQuestionList()">搜索</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <el-tabs v-model="activeName" type="card" @tab-click="handleTabClick">
        <el-tab-pane label="全部" name="first">
          <el-alert :title="'数据一共 '+total+' 条'" type="info" show-icon :closable="false" style="margin-bottom:15px">
          </el-alert>
          <el-table :data="questionList" border stripe style="width: 100%">
            <el-table-column prop="number" label="试题编号" width="150">
            </el-table-column>
            <el-table-column prop="subject" label="学科" width="120">
            </el-table-column>
            <el-table-column prop="catalog" label="目录" width="120">
            </el-table-column>
            <el-table-column prop="questionType" label="题型" width="120">
              <template v-slot="{row}">
                <div v-if="row.questionType==='1'">单选</div>
                <div v-else-if="row.questionType==='2'">多选</div>
                <div v-else>简答</div>
              </template>
            </el-table-column>
            <el-table-column prop="question" label="题干" width="300">
              <template slot-scope="scope">
                <div v-html="scope.row.question"></div>
              </template>
            </el-table-column>
            <el-table-column prop="addDate" label="录入时间" width="160">
              <template v-slot="{row}">
                {{row.addDate | parseTimeByString}}
              </template>
            </el-table-column>
            <el-table-column prop="difficulty" label="难度" width="120">
              <template v-slot="{row}">
                <div v-if="row.difficulty==='1'">简单</div>
                <div v-else-if="row.difficulty==='2'">一般</div>
                <div v-else>困难</div>
              </template>
            </el-table-column>
            <el-table-column prop="creator" label="录入人" width="120">
            </el-table-column>
            <el-table-column prop="chkState" label="审核状态" width="120">
              <template v-slot="{row}">
                <div v-if="row.chkState===0">待审核</div>
                <div v-else-if="row.chkState===1">已审核</div>
                <div v-else>已拒绝</div>
              </template>
            </el-table-column>
            <el-table-column prop="chkRemarks" label="审核意见" width="120">
            </el-table-column>
            <el-table-column prop="chkUser" label="审核人" width="120">
            </el-table-column>
            <el-table-column prop="publishState" label="发布状态" width="120">
              <template v-slot="{row}">
                <div v-if="row.publishState===0&&row.chkState===1">已下架</div>
                <div v-else-if="row.publishState===1&&row.chkState===1">已发布</div>
                <div v-else>待发布</div>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="200" align="center">
              <template slot-scope="scope">
                <el-button @click="getPreviewObj(scope.row)" type="text" size="small">预览</el-button>
                <el-button type="text" size="small" :disabled="scope.row.chkState!==0?true:false"
                  @click="auditTopic(scope.row)">审核
                </el-button>
                <el-button type="text" size="small" :disabled="scope.row.publishState===1?true:false"
                  @click="edit(scope.row)">修改
                </el-button>
                <el-button type="text" size="small" v-if="scope.row.publishState===1" @click="putTopic(scope.row)">下架
                </el-button>
                <el-button type="text" size="small" v-else @click="putTopic(scope.row)">上架</el-button>
                <el-button type="text" size="small" :disabled="scope.row.publishState===1?true:false"
                  @click="delTopic(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="待审核" name="second">
          <el-alert :title="'数据一共 '+total+' 条'" type="info" show-icon :closable="false" style="margin-bottom:15px">
          </el-alert>
          <el-table :data="questionList" border stripe style="width: 100%">
            <el-table-column prop="number" label="试题编号" width="150">
            </el-table-column>
            <el-table-column prop="subject" label="学科" width="120">
            </el-table-column>
            <el-table-column prop="catalog" label="目录" width="120">
            </el-table-column>
            <el-table-column prop="questionType" label="题型" width="120">
              <template v-slot="{row}">
                <div v-if="row.questionType==='1'">单选</div>
                <div v-else-if="row.questionType==='2'">多选</div>
                <div v-else>简答</div>
              </template>
            </el-table-column>
            <el-table-column prop="question" label="题干" width="300">
              <template slot-scope="scope">
                <div v-html="scope.row.question"></div>
              </template>
            </el-table-column>
            <el-table-column prop="addDate" label="录入时间" width="160">
              <template v-slot="{row}">
                {{row.addDate | parseTimeByString}}
              </template>
            </el-table-column>
            <el-table-column prop="difficulty" label="难度" width="120">
              <template v-slot="{row}">
                <div v-if="row.difficulty==='1'">简单</div>
                <div v-else-if="row.difficulty==='2'">一般</div>
                <div v-else>困难</div>
              </template>
            </el-table-column>
            <el-table-column prop="creator" label="录入人" width="120">
            </el-table-column>
            <el-table-column prop="chkState" label="审核状态" width="120">
              <template v-slot="{row}">
                <div v-if="row.chkState===0">待审核</div>
                <div v-else-if="row.chkState===1">已审核</div>
                <div v-else>已拒绝</div>
              </template>
            </el-table-column>
            <el-table-column prop="chkRemarks" label="审核意见" width="120">
            </el-table-column>
            <el-table-column prop="chkUser" label="审核人" width="120">
            </el-table-column>
            <el-table-column prop="publishState" label="发布状态" width="120">
              <template v-slot="{row}">
                <div v-if="row.publishState===0&&row.chkState===1">已下架</div>
                <div v-else-if="row.publishState===1&&row.chkState===1">已发布</div>
                <div v-else>待发布</div>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="200" align="center">
              <template slot-scope="scope">
                <el-button @click="getPreviewObj(scope.row)" type="text" size="small">预览</el-button>
                <el-button type="text" size="small" :disabled="scope.row.chkState!==0?true:false"
                  @click="auditTopic(scope.row)">审核
                </el-button>
                <el-button type="text" size="small" :disabled="scope.row.publishState===1?true:false"
                  @click="edit(scope.row)">修改
                </el-button>
                <el-button type="text" size="small" v-if="scope.row.publishState===1" @click="putTopic(scope.row)">下架
                </el-button>
                <el-button type="text" size="small" v-else @click="putTopic(scope.row)">上架</el-button>
                <el-button type="text" size="small" :disabled="scope.row.publishState===1?true:false"
                  @click="delTopic(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="已审核" name="third">
          <el-alert :title="'数据一共 '+total+' 条'" type="info" show-icon :closable="false" style="margin-bottom:15px">
          </el-alert>
          <el-table :data="questionList" border stripe style="width: 100%">
            <el-table-column prop="number" label="试题编号" width="150">
            </el-table-column>
            <el-table-column prop="subject" label="学科" width="120">
            </el-table-column>
            <el-table-column prop="catalog" label="目录" width="120">
            </el-table-column>
            <el-table-column prop="questionType" label="题型" width="120">
              <template v-slot="{row}">
                <div v-if="row.questionType==='1'">单选</div>
                <div v-else-if="row.questionType==='2'">多选</div>
                <div v-else>简答</div>
              </template>
            </el-table-column>
            <el-table-column prop="question" label="题干" width="300">
              <template slot-scope="scope">
                <div v-html="scope.row.question"></div>
              </template>
            </el-table-column>
            <el-table-column prop="addDate" label="录入时间" width="160">
              <template v-slot="{row}">
                {{row.addDate | parseTimeByString}}
              </template>
            </el-table-column>
            <el-table-column prop="difficulty" label="难度" width="120">
              <template v-slot="{row}">
                <div v-if="row.difficulty==='1'">简单</div>
                <div v-else-if="row.difficulty==='2'">一般</div>
                <div v-else>困难</div>
              </template>
            </el-table-column>
            <el-table-column prop="creator" label="录入人" width="120">
            </el-table-column>
            <el-table-column prop="chkState" label="审核状态" width="120">
              <template v-slot="{row}">
                <div v-if="row.chkState===0">待审核</div>
                <div v-else-if="row.chkState===1">已审核</div>
                <div v-else>已拒绝</div>
              </template>
            </el-table-column>
            <el-table-column prop="chkRemarks" label="审核意见" width="120">
            </el-table-column>
            <el-table-column prop="chkUser" label="审核人" width="120">
            </el-table-column>
            <el-table-column prop="publishState" label="发布状态" width="120">
              <template v-slot="{row}">
                <div v-if="row.publishState===0&&row.chkState===1">已下架</div>
                <div v-else-if="row.publishState===1&&row.chkState===1">已发布</div>
                <div v-else>待发布</div>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="200" align="center">
              <template slot-scope="scope">
                <el-button @click="getPreviewObj(scope.row)" type="text" size="small">预览</el-button>
                <el-button type="text" size="small" :disabled="scope.row.chkState!==0?true:false"
                  @click="auditTopic(scope.row)">审核
                </el-button>
                <el-button type="text" size="small" :disabled="scope.row.publishState===1?true:false"
                  @click="edit(scope.row)">修改
                </el-button>
                <el-button type="text" size="small" v-if="scope.row.publishState===1" @click="putTopic(scope.row)">下架
                </el-button>
                <el-button type="text" size="small" v-else @click="putTopic(scope.row)">上架</el-button>
                <el-button type="text" size="small" :disabled="scope.row.publishState===1?true:false"
                  @click="delTopic(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="已拒绝" name="fourth">
          <el-alert :title="'数据一共 '+total+' 条'" type="info" show-icon :closable="false" style="margin-bottom:15px">
          </el-alert>
          <el-table :data="questionList" border stripe style="width: 100%">
            <el-table-column prop="number" label="试题编号" width="150">
            </el-table-column>
            <el-table-column prop="subject" label="学科" width="120">
            </el-table-column>
            <el-table-column prop="catalog" label="目录" width="120">
            </el-table-column>
            <el-table-column prop="questionType" label="题型" width="120">
              <template v-slot="{row}">
                <div v-if="row.questionType==='1'">单选</div>
                <div v-else-if="row.questionType==='2'">多选</div>
                <div v-else>简答</div>
              </template>
            </el-table-column>
            <el-table-column prop="question" label="题干" width="300">
              <template slot-scope="scope">
                <div v-html="scope.row.question"></div>
              </template>
            </el-table-column>
            <el-table-column prop="addDate" label="录入时间" width="160">
              <template v-slot="{row}">
                {{row.addDate | parseTimeByString}}
              </template>
            </el-table-column>
            <el-table-column prop="difficulty" label="难度" width="120">
              <template v-slot="{row}">
                <div v-if="row.difficulty==='1'">简单</div>
                <div v-else-if="row.difficulty==='2'">一般</div>
                <div v-else>困难</div>
              </template>
            </el-table-column>
            <el-table-column prop="creator" label="录入人" width="120">
            </el-table-column>
            <el-table-column prop="chkState" label="审核状态" width="120">
              <template v-slot="{row}">
                <div v-if="row.chkState===0">待审核</div>
                <div v-else-if="row.chkState===1">已审核</div>
                <div v-else>已拒绝</div>
              </template>
            </el-table-column>
            <el-table-column prop="chkRemarks" label="审核意见" width="120">
            </el-table-column>
            <el-table-column prop="chkUser" label="审核人" width="120">
            </el-table-column>
            <el-table-column prop="publishState" label="发布状态" width="120">
              <template v-slot="{row}">
                <div v-if="row.publishState===0&&row.chkState===1">已下架</div>
                <div v-else-if="row.publishState===1&&row.chkState===1">已发布</div>
                <div v-else>待发布</div>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="200" align="center">
              <template slot-scope="scope">
                <el-button @click="getPreviewObj(scope.row)" type="text" size="small">预览</el-button>
                <el-button type="text" size="small" :disabled="scope.row.chkState!==0?true:false"
                  @click="auditTopic(scope.row)">审核
                </el-button>
                <el-button type="text" size="small" :disabled="scope.row.publishState===1?true:false"
                  @click="edit(scope.row)">修改
                </el-button>
                <el-button type="text" size="small" v-if="scope.row.publishState===1" @click="putTopic(scope.row)">下架
                </el-button>
                <el-button type="text" size="small" v-else @click="putTopic(scope.row)">上架</el-button>
                <el-button type="text" size="small" :disabled="scope.row.publishState===1?true:false"
                  @click="delTopic(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <el-pagination style="text-align: right;margin-top:15px" @size-change="handleSizeChange" background
        @current-change="handleCurrentChange" :current-page="questionInfo.page" :page-sizes="[5, 10, 20, 50]"
        :page-size="questionInfo.pagesize" layout="prev,pager,next,sizes,jumper" :total="total">
      </el-pagination>
    </el-card>

    <el-dialog title="题目预览" :visible.sync="topicDialogVisible" width="55%" @close="topicDialogClose">
      <el-row>
        <el-col :span="6" style="margin:10px 0">
          <div v-if="previewobj.questionType==='1'">【题型】：单选题</div>
          <div v-else-if="previewobj.questionType==='2'">【题型】：多选题</div>
          <div v-else>【题型】：简答题</div>
        </el-col>
        <el-col :span="6" style="margin:10px 0">
          【编号】：{{previewobj.id}}
        </el-col>
        <el-col :span="6" style="margin:10px 0">
          <div v-if="previewobj.difficulty==='1'">【题型】：简单</div>
          <div v-else-if="previewobj.difficulty==='2'">【题型】：一般</div>
          <div v-else>【题型】：困难</div>
        </el-col>
        <el-col :span="6" style="margin:10px 0">
          【标签】：{{previewobj.tags}}
        </el-col>
        <el-col :span="6" style="margin:10px 0">
          【学科】：{{previewobj.subjectName}}
        </el-col>
        <el-col :span="6" style="margin:10px 0">
          【目录】：{{previewobj.directoryName}}
        </el-col>
        <el-col :span="6" style="margin:10px 0">
          【方向】：{{previewobj.direction}}
        </el-col>
      </el-row>
      <hr>
      <div>【题干】：</div>
      <div v-html="previewobj.question" style="color:blue"></div>
      <div v-if="previewobj.questionType==='1'">
        单选题 选项：（以下选中的选项为正确答案）
        <div v-for="item in previewobj.options" :key="item.id" style="margin-top: 10px;line-height: 23px;">
          <el-radio @change="radiochange" v-model="radio" :label="item.isRight">
            {{item.title}}
          </el-radio>
        </div>
      </div>
      <div v-else-if="previewobj.questionType==='2'">
        多选题 选项：（以下选中的选项为正确答案）
        <el-checkbox v-for="item in previewobj.options" :key="item.id" v-model="item.checked" @change="checkchange">
          {{item.title}}
        </el-checkbox>
      </div>
      <div v-else></div>
      <hr>
      <div>
        【参考答案】：
        <el-button type="danger" size="small" @click="clickVideo">视频答案预览</el-button>
        <div class="video" v-if="videoshow">
          <video id="myvideo" :src="previewobj.videoURL" controls autoplay></video>
        </div>
      </div>
      <hr>
      【答案解析】：
      <div v-html="previewobj.answer" style="display:inline-block">
      </div>
      <hr>
      <div>
        【题目备注】：{{previewobj.remarks}}
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="topicDialogVisible = false">关闭</el-button>
      </span>
    </el-dialog>

    <el-dialog title="题目审核" :visible.sync="auditDialogVisible" width="20%" @close="auditDialogClose">
      <el-radio v-model="auditObj.chkState" :label="1">通过</el-radio>
      <el-radio v-model="auditObj.chkState" :label="2">拒绝</el-radio>
      <el-input type="textarea" :rows="2" placeholder="请输入审核意见" v-model="auditObj.chkRemarks" style="margin-top:20px">
      </el-input>
      <span slot="footer" class="dialog-footer">
        <el-button @click="auditDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="auditConfirm">确 定</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
import { difficulty, questionType, direction } from '@/api/hmmm/constants'
import { provinces, citys } from '@/api/hmmm/citys.js'
export default {
  data () {
    return {
      // 如果参数的值为null，那么上传参数时不会携带
      searchForm: {
        // 学科
        subjectID: '',
        // 二级目录
        catalogID: '',
        // 难度
        difficulty: '',
        // 试题类型
        questionType: '',
        // 标签
        tags: '',
        // 企业所在地省份
        province: '',
        // 企业所在城市
        city: '',
        // 关键字
        keyword: '',
        // 题目备注
        remarks: '',
        // 企业简称
        shortName: '',
        // 方向
        direction: '',
        // 录入人
        creatorID: ''
      },
      userList: [],
      subjectList: [],
      secondList: [],
      tagsList: [],
      provinceList: [],
      cityList: [],
      questionType,
      difficulty: difficulty,
      direction: direction,
      questionInfo: {
        page: 1,
        pagesize: 5
      },
      activeName: 'first',
      questionList: [],
      total: 0,
      topicDialogVisible: false,
      previewobj: {},
      radio: 1,
      videoshow: false,
      auditDialogVisible: false,
      auditObj: {
        chkState: 1,
        chkRemarks: '',
        id: ''
      },
      putTopicObj: {

      }
    }
  },
  methods: {
    edit (row) {
      this.$router.push({
        path: 'new',
        query: { id: row.id, subjectID: row.subjectID }
      })
    },
    async delTopic (row) {
      const result = await this.$confirm('此操作将永久删除该题目, 是否继续 ? ', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).catch(err => err)
      if (result !== 'confirm') {
        return this.$message.info('已取消删除')
      }
      await this.$store.dispatch('removeTopic', row.id)
      this.$message.success('删除成功')
      this.getQuestionList()
    },
    async putTopic (row) {
      let str = ''
      if (row.publishState === 1) {
        str = '下架'
      } else {
        str = '上架'
      }

      const result = await this.$confirm('您确认' + str + '这道题目吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).catch(err => err)
      if (result !== 'confirm') {
        return this.$message.info('已取消' + str)
      }
      if (row.publishState === 1) {
        row.publishState = 0
      } else {
        row.publishState = 1
      }
      this.putTopicObj.id = row.id
      this.putTopicObj.publishState = row.publishState

      await this.$store.dispatch('setChoicePublish', this.putTopicObj)
      this.$message.success(str + '成功')
      this.getQuestionList()
    },
    auditDialogClose () {
      this.auditObj = {
        chkState: 1,
        chkRemarks: '',
        id: ''
      }
    },
    async auditConfirm () {
      if (this.auditObj.chkRemarks.length > 0) {
        await this.$store.dispatch('setChoiceCheck', this.auditObj)
        this.auditDialogVisible = false
        this.getQuestionList()
      } else {
        this.$message.warning('请输入审核意见')
      }
    },
    auditTopic (row) {
      this.auditDialogVisible = true
      this.auditObj.id = row.id
    },
    topicDialogClose () {
      this.videoshow = false
      this.previewobj = {}
    },
    clickVideo () {
      this.videoshow = true
      // const video = document.getElementById('myvideo')
      // video.play()
    },
    checkchange () {
      if (this.previewobj.questionType === '2') {
        this.previewobj.options.forEach(item => {
          if (item.isRight === 1) {
            item.checked = true
          } else {
            item.checked = false
          }
        })
      }
    },
    radiochange () {
      this.radio = 1
    },
    async getPreviewObj (row) {
      this.topicDialogVisible = true
      const { data: res } = await this.$store.dispatch('getPreviewObj', row.id)
      this.previewobj = res
      // 也可用数组做,数组里存checkbox得值,checkboxgroup+checkbox
      if (this.previewobj.questionType === '2') {
        this.previewobj.options.forEach(item => {
          if (item.isRight === 1) {
            item.checked = true
          } else {
            item.checked = false
          }
        })
      }
    },
    handleCurrentChange (newpage) {
      this.questionInfo.page = newpage
      this.getQuestionList()
    },
    handleSizeChange (newsize) {
      this.questionInfo.pagesize = newsize
      this.getQuestionList()
    },
    async handleTabClick (tab, event) {
      if (tab.index === '0') {
        delete this.questionInfo.chkState
        const { data: res } = await this.$store.dispatch('getQuestionList', this.questionInfo)
        this.questionList = res.items
        this.total = res.counts
      }
      if (tab.index === '1') {
        this.questionInfo = { ...this.questionInfo, ...{ chkState: 0 } }
        const { data: res } = await this.$store.dispatch('getQuestionList', this.questionInfo)
        this.questionList = res.items
        this.total = res.counts
      }
      if (tab.index === '2') {
        this.questionInfo = { ...this.questionInfo, ...{ chkState: 1 } }
        const { data: res } = await this.$store.dispatch('getQuestionList', this.questionInfo)
        this.questionList = res.items
        this.total = res.counts
      }
      if (tab.index === '3') {
        this.questionInfo = { ...this.questionInfo, ...{ chkState: 2 } }
        const { data: res } = await this.$store.dispatch('getQuestionList', this.questionInfo)
        this.questionList = res.items
        this.total = res.counts
      }
    },
    async selectChanged (value) {
      const { data: res1 } = await this.$store.dispatch('getSecondList', value)
      const { data: res2 } = await this.$store.dispatch('getTagsList', value)
      this.secondList = res1
      this.tagsList = res2
    },
    selectListChanged (value) {
      this.searchForm.city = ''
      this.cityList = citys(value)
    },
    async getSubjectList () {
      const { data: res } = await this.$store.dispatch('getSimpleList')
      this.subjectList = res
    },
    async getUserList () {
      const { data: res } = await this.$store.dispatch('getUserList')
      this.userList = res
    },
    async getQuestionList () {
      const { keyword, subjectID } = this.searchForm
      if (keyword.length > 0) {
        this.questionInfo = { ...this.questionInfo, keyword }
      }
      if ((subjectID + '').length > 0) {
        this.questionInfo = { ...this.questionInfo, subjectID }
      }
      const { data: res } = await this.$store.dispatch('getQuestionList', this.questionInfo)
      this.questionList = res.items
      this.total = res.counts
    },
    clear () {
      this.searchForm.province = ''
      this.searchForm.city = ''
      this.questionInfo = {
        page: 1,
        pagesize: 5
      }
      this.$refs.searchFormRefs.resetFields()
    }
  },
  created () {
    this.getQuestionList()
    this.getSubjectList()
    this.getUserList()
    this.provinceList = provinces()
  }
}
</script>

<style scoped lang='less'>
.el-card {
  margin: 15px;
  .q_title {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
  }
}
.el-select {
  width: 100%;
}
// /deep/ .singlechoice .el-radio {
//   display: block;
//   margin-top: 10px;
//   line-height: 23px;
//   white-space: normal;
//   margin-right: 0;
// }
/deep/ .el-checkbox {
  display: block;
  margin-top: 10px;
  line-height: 23px;
  white-space: normal;
  margin-right: 0;
}
.video {
  width: 400px;
  height: 300px;
}
video {
  width: 100%;
  height: 100%;
}
</style>
